<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
      <title>Controller Page Web Implementation | HiAPI-C# 2025 </title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="title" content="Controller Page Web Implementation | HiAPI-C# 2025 ">
      
      
      <link rel="icon" href="../../../../img/HiAPI.favicon.ico">
      <link rel="stylesheet" href="../../../../public/docfx.min.css">
      <link rel="stylesheet" href="../../../../public/main.css">
      <meta name="docfx:navrel" content="../../../../toc.html">
      <meta name="docfx:tocrel" content="../../toc.html">
      
      <meta name="docfx:rel" content="../../../../">
      
      
      
      <meta name="loc:inThisArticle" content="In this article">
      <meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
      <meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
      <meta name="loc:tocFilter" content="Filter by title">
      <meta name="loc:nextArticle" content="Next">
      <meta name="loc:prevArticle" content="Previous">
      <meta name="loc:themeLight" content="Light">
      <meta name="loc:themeDark" content="Dark">
      <meta name="loc:themeAuto" content="Auto">
      <meta name="loc:changeTheme" content="Change theme">
      <meta name="loc:copy" content="Copy">
      <meta name="loc:downloadPdf" content="Download PDF">

      <script type="module" src="./../../../../public/docfx.min.js"></script>

      <script>
        const theme = localStorage.getItem('theme') || 'auto'
        document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
      </script>

  </head>

  <body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
    <header class="bg-body border-bottom">
      <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
        <div class="container-xxl flex-nowrap">
          <a class="navbar-brand" href="../../../../index.html">
            <img id="logo" class="svg" src="../../../../img/HiAPI.logo.png" alt="">
            
          </a>
          <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
            <i class="bi bi-three-dots"></i>
          </button>
          <div class="collapse navbar-collapse" id="navpanel">
            <div id="navbar">
              <form class="search" role="search" id="search">
                <i class="bi bi-search"></i>
                <input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
              </form>
            </div>
          </div>
        </div>
      </nav>
    </header>

    <main class="container-xxl">
      <div class="toc-offcanvas">
        <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
          <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
          </div>
          <div class="offcanvas-body">
            <nav class="toc" id="toc"></nav>
          </div>
        </div>
      </div>

      <div class="content">
        <div class="actionbar">
          <button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
            <i class="bi bi-list"></i>
          </button>

          <nav id="breadcrumb"></nav>
        </div>

        <article data-uid="">
          <h1 id="controller-page-web-implementation">Controller Page Web Implementation</h1>

<p>This document describes the web implementation of the Controller Page in the HiNC-2025-webservice project.</p>
<h2 id="overview">Overview</h2>
<p>The Controller Page web implementation consists of:</p>
<ul>
<li>Backend API controller (<code>ControllerController.cs</code>)</li>
<li>Frontend HTML, JavaScript, and CSS files</li>
<li>Integration with the rendering canvas and toolbar components</li>
</ul>
<h2 id="backend-implementation">Backend Implementation</h2>
<h3 id="controllercontrollercs">ControllerController.cs</h3>
<p>Located at <code>Controller/ControllerController.cs</code>, this API controller provides endpoints for managing CNC controller settings:</p>
<h4 id="endpoints">Endpoints</h4>
<ul>
<li><code>GET /api/controller/cnc-brand</code> - Gets the current CNC brand</li>
<li><code>PUT /api/controller/cnc-brand</code> - Updates the CNC brand</li>
<li><code>GET /api/controller/machine-config</code> - Gets machine configuration</li>
<li><code>PUT /api/controller/machine-config</code> - Updates machine configuration</li>
<li><code>GET /api/controller/general-config</code> - Gets general configuration settings</li>
<li><code>PUT /api/controller/general-config</code> - Updates general configuration</li>
<li><code>GET /api/controller/iso-coordinate-table</code> - Gets the ISO coordinate table</li>
<li><code>PUT /api/controller/iso-coordinate-table/{index}</code> - Updates an ISO coordinate entry</li>
<li><code>GET /api/controller/heidenhain-datum-preset-table</code> - Gets the Heidenhain datum preset table</li>
<li><code>PUT /api/controller/heidenhain-datum-preset-table/{index}</code> - Updates a Heidenhain datum preset entry</li>
<li><code>GET /api/controller/heidenhain-datum-shift-table</code> - Gets the Heidenhain datum shift table</li>
<li><code>PUT /api/controller/heidenhain-datum-shift-table/{index}</code> - Updates a Heidenhain datum shift entry</li>
<li><code>GET /api/controller/milling-tool-offset-table</code> - Gets the milling tool offset table</li>
<li><code>PUT /api/controller/milling-tool-offset-table</code> - Updates the milling tool offset table</li>
<li><code>GET /api/controller/ideal-offset-dependent</code> - Gets the ideal offset dependent setting</li>
<li><code>PUT /api/controller/ideal-offset-dependent</code> - Updates the ideal offset dependent setting</li>
<li><code>POST /api/controller/set-ideal-offset-from-toolhouse</code> - Sets ideal offset based on tool house</li>
<li><code>POST /api/controller/initialize-display</code> - Initializes the display engine for rendering</li>
</ul>
<h2 id="frontend-implementation">Frontend Implementation</h2>
<h3 id="html-structure">HTML Structure</h3>
<p>The main HTML file (<code>wwwroot/controller/controller-panel.html</code>) contains:</p>
<ul>
<li>Management panel with tabs for different configuration sections</li>
<li>Viewer panel with rendering canvas for 3D visualization</li>
<li>Responsive layout with resizable panels</li>
</ul>
<h3 id="javascript-components">JavaScript Components</h3>
<p>The frontend uses Vue.js framework with ES modules for component-based architecture.</p>
<h4 id="controller-paneljs">controller-panel.js</h4>
<p>Main Vue.js component that orchestrates the controller page:</p>
<ul>
<li>Imports and registers all sub-components (tabs, toolbars, rendering canvas)</li>
<li>Manages global state (CNC brand, rendering connection)</li>
<li>Handles tab switching and dynamic component loading</li>
<li>Initializes display engine and rendering connections</li>
</ul>
<p>Key features:</p>
<ul>
<li>Component-based architecture using Vue.js</li>
<li>Dynamic tab components loaded from separate files</li>
<li>Brand-specific UI updates (showing/hiding Heidenhain tabs)</li>
<li>Integration with rendering canvas and toolbars</li>
</ul>
<h4 id="tab-components">Tab Components</h4>
<p>Each configuration tab is implemented as a separate Vue.js component:</p>
<ul>
<li><code>coordinate-table-tab.js</code> - ISO coordinate table management</li>
<li><code>datum-preset-tab.js</code> - Heidenhain datum preset table (brand-specific)</li>
<li><code>datum-shift-tab.js</code> - Heidenhain datum shift table (brand-specific)</li>
<li><code>offset-table-tab.js</code> - Tool offset table with ideal offset settings</li>
<li><code>machine-tab.js</code> - Machine configuration with axis limits (degrees for rotary axes)</li>
<li><code>brand-tab.js</code> - CNC brand selection</li>
<li><code>config-tab.js</code> - General configuration settings</li>
</ul>
<h4 id="controller-extended-toolbarjs">controller-extended-toolbar.js</h4>
<p>Vue.js component for the extended toolbar that provides:</p>
<ul>
<li>Rendering flags dropdown menu (similar to WPF's RenderingFlagSubmenu)</li>
<li>Controller-specific rendering options (Machine, Coordinates, ISO, Datum, etc.)</li>
<li>Brand-aware rendering flags (Heidenhain-specific options)</li>
<li>Integration with display engine for real-time updates</li>
</ul>
<h3 id="css-styling">CSS Styling</h3>
<p>Two CSS files provide styling:</p>
<ul>
<li><code>controller-panel.css</code> - Main panel layout and component styles
<ul>
<li>Two-column responsive layout using flexbox</li>
<li>Tab navigation and content styling</li>
<li>Form controls with special handling for checkboxes</li>
<li>Overrides global styles for proper checkbox display</li>
</ul>
</li>
<li><code>controller-extended-toolbar.css</code> - Toolbar-specific styles
<ul>
<li>Dropdown menu styling</li>
<li>Button and icon styling</li>
<li>Consistent with player toolbar design</li>
</ul>
</li>
</ul>
<h2 id="integration-points">Integration Points</h2>
<h3 id="with-main-application">With Main Application</h3>
<p>The controller page is integrated into the main application through:</p>
<ul>
<li>Navigation menu in <code>index.html</code></li>
<li>Route handling in <code>main.js</code></li>
<li>Iframe embedding for isolated functionality</li>
</ul>
<h3 id="with-project-service">With Project Service</h3>
<p>The controller utilizes the <code>IProjectService</code> to:</p>
<ul>
<li>Access the current <a class="xref" href="../../../../api/Hi.MachiningProcs.MachiningProject.html">MachiningProject</a></li>
<li>Retrieve and update <a class="xref" href="../../../../api/Hi.Numerical.NcEnv.html">NcEnv</a> settings</li>
<li>Save changes to the project</li>
</ul>
<h3 id="with-rendering-engine">With Rendering Engine</h3>
<p>The controller page integrates with:</p>
<ul>
<li><a class="xref" href="../../../../api/Hi.Disp.DispEngine.html">DispEngine</a> for 3D visualization</li>
<li><a class="xref" href="../../../../api/Hi.MachiningProcs.MachiningProjectDisplayee.html">MachiningProjectDisplayee</a> for rendering project data</li>
<li>Custom rendering flags for controller-specific visualizations</li>
</ul>
<h2 id="key-differences-from-wpf-implementation">Key Differences from WPF Implementation</h2>
<ol>
<li><strong>Asynchronous Operations</strong>: All data operations are asynchronous using fetch API</li>
<li><strong>Component Architecture</strong>: Vue.js components instead of WPF UserControls</li>
<li><strong>Web-based Rendering</strong>: Uses WebGL-based rendering canvas instead of WPF controls</li>
<li><strong>Responsive Design</strong>: Two-column layout with CSS flexbox for better screen utilization</li>
<li><strong>Unit Conversion</strong>: Frontend handles degree/radian conversion for rotary axes</li>
<li><strong>Granular API</strong>: Split NcEnv into multiple focused endpoints instead of single large DTO</li>
<li><strong>Toolbar Integration</strong>: Reuses rendering flag patterns from player section</li>
</ol>
<h2 id="implementation-details">Implementation Details</h2>
<h3 id="data-transfer-objects-dtos">Data Transfer Objects (DTOs)</h3>
<p>The backend uses several DTOs to simplify complex object serialization:</p>
<ul>
<li><code>IsoCoordinateTableEntry</code> - For ISO coordinate table entries</li>
<li><code>DatumTableEntry</code> - For Heidenhain datum tables</li>
<li><code>MachineConfigDto</code> - For machine configuration settings</li>
<li><code>GeneralConfigDto</code> - For general configuration settings</li>
</ul>
<h3 id="unit-handling">Unit Handling</h3>
<ul>
<li>Backend stores rotary axis values in radians (following HiAPI conventions)</li>
<li>Frontend displays and accepts input in degrees for user-friendliness</li>
<li>Conversion happens in the Vue.js components (<code>radToDeg</code> and <code>degToRad</code> functions)</li>
</ul>
<h3 id="rendering-flag-management">Rendering Flag Management</h3>
<p>The controller uses specific rendering flags for visualization:</p>
<ul>
<li>Flag indices follow the <code>RenderingFlag</code> enum structure</li>
<li>Controller-specific flags include: Coordinate, HeidenhainDatumPreset, HeidenhainDatumShift, Stock, AxisLimits</li>
<li>Flags are synchronized between frontend state and display engine</li>
</ul>
<h2 id="future-enhancements">Future Enhancements</h2>
<ul>
<li>Implement ObjectManagementMenuButton component for file management</li>
<li>Add undo/redo functionality</li>
<li>Implement keyboard shortcuts</li>
<li>Add client-side validation for numeric inputs</li>
<li>Implement batch updates for better performance</li>
<li>Add tooltips for configuration options</li>
</ul>

</article>

        <div class="contribution d-print-none">
        </div>

        <div class="next-article d-print-none border-top" id="nextArticle"></div>

      </div>

      <div class="affix">
        <nav id="affix"></nav>
      </div>
    </main>

    <div class="container-xxl search-results" id="search-results"></div>

    <footer class="border-top text-secondary">
      <div class="container-xxl">
        <div class="flex-fill">
          <span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
        </div>
      </div>
    </footer>
  </body>
</html>
